<?php $n_label = count($label); if($n_label > 0){?>
<?php if($mess != '') echo "<p>$mess</p>";?>
<h2>Từ ngày <?php echo date('d/m/Y', strtotime($fromdate));?> đến ngày <?php echo date('d/m/Y', strtotime($todate));?></h2>
<table width="100%" cellspacing="0" cellpadding="0" border="1" style="width:100%; border-collapse:collapse; border-color: #ccc;">
    <tr>
        <td width="20" style="background: #ddd; padding: 3px 5px;">
            Stt
        </td>
        <?php foreach ($label as $title){?>
        <td style="background: #ddd; padding: 3px 5px;">
            <?php echo $title;?>
        </td>
        <?php }?>
    </tr>
    <?php $i = 0; foreach ($items as $item){ $i++;?>
    <tr>
        <td style="text-align:center; padding: 3px 5px;">
            <?php echo $i;?>
        </td>
        <?php $ii = 0; foreach ($label as $title){ $ii++;?>
        <td style="text-align:<?php if(is_numeric($item->$title)) echo 'right';?>; padding: 3px 5px;">
            <?php echo (is_numeric($item->$title) ? number_format($item->$title) : $item->$title);?>
        </td>
        <?php }?>
    </tr>
    <?php }?>
    <tr>
    	<td style="background: #ddd; padding: 3px 5px;">Tổng</td>
    	<?php foreach ($label as $title){?>
        <td style="background: #ddd; padding: 3px 5px; text-align: <?php echo is_numeric($totalValue[$title]) ? 'right' : 'left';?>">
            <?php echo is_numeric($totalValue[$title]) ? number_format($totalValue[$title]) : $totalValue[$title];?>
        </td>
        <?php }?>
    </tr>
</table>
<br />Regards,
<?php }?>
